Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyline volume #1125

Merged
merged 31 commits into from
Oct 4, 2013
Merged

Polyline volume #1125

merged 31 commits into from
Oct 4, 2013

Conversation

hpinkos
Copy link
Contributor

@hpinkos hpinkos commented Sep 5, 2013

Geometry that takes a line and a polygon as parameters, then extrudes the polygon over the line. Has the option to round, miter or bevel corners.

VertexFormat,
WindingOrder) {
"use strict";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 6, 2013

Did you use the debugging aids to visualize the computed bounding sphere, texture coordinates, and normal/binormal/tangents?

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 6, 2013

Don't forget to update the tutorial. Even before we merge is fine; the tutorial is still a draft and I expect we'll merge this quickly.

var tube = new Cesium.GeometryInstance({
geometry: new Cesium.PolylineVolumeGeometry({
polylinePositions : positions,
vertexFormat: Cesium.VertexFormat.ALL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace before the : throughout. Sorry. Probably should run the formatter assuming it works on HTML files.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 6, 2013

The Sandcastle example is pretty awesome.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 6, 2013

Looks like the triangle winding order is wrong sometimes.

image

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 6, 2013

I made a small change to the Sandcastle example:

    positions = ellipsoid.cartographicArrayToCartesianArray([
         Cesium.Cartographic.fromDegrees(-90.0, 10.0, 100000.0),
         Cesium.Cartographic.fromDegrees(-95.0, 15.0, 100000.0),
         Cesium.Cartographic.fromDegrees(-100.0, 15.0, 100000.0)
     ]);

image

In general, I would expect that the 2D origin in the plane of the polygon would be centered along the polyline, and then the height argument adjusts from there.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 6, 2013

We should take into account the height of each position in polylinePositions. Given this, I'm not sure that we need the height property.

@hpinkos
Copy link
Contributor Author

hpinkos commented Sep 6, 2013

Looks like the triangle winding order is wrong sometimes.

The missing triangles is related to Issue #1093. If you switch the order of the geometries in the geometryInstances array parameter passed to the primitive, the orange one will be missing triangles instead.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 6, 2013

Some of the shading can be jarring because we are using averaged vertex normals. For the wall and other primitives (including the corridor), we duplicate the vertex so we can have better normals. We'll need to do that here for the corridor primitive to use it. We should just be able to post-process the polygon (make a copy!) before extruding it. I would do it based on a heuristic of the angle between adjacent edges so we only duplicate vertices that need to be. This can be a generic function in PolygonPipeline so we can use it for the wall.

With beveled corners:
image

@hpinkos
Copy link
Contributor Author

hpinkos commented Sep 6, 2013

@pjcozzi I am duplicating the points:
image

With single points the bevel looks all rounded and shiny:
image

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 6, 2013

Looks like the triangle winding order is wrong sometimes.

The missing triangles is related to Issue #1093. If you switch the order of the geometries in the geometryInstances array parameter passed to the primitive, the orange one will be missing triangles instead.

CC @bagnell

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 6, 2013

@pjcozzi I am duplicating the points...

OK.

var indicesCount = (length - 1) * (shapeLength) * 6 + firstEndIndices.length * 2;
var indices = IndexDatatype.createTypedArray(vertexCount, indicesCount);
var i, j;
var LL, UL, UR, LR;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally only use upper case for constants.

var pos = positions[i];
cartographic = ellipsoid.cartesianToCartographic(pos, cartographic);
heights[i] = cartographic.height;
positions[i] = ellipsoid.scaleToGeodeticSurface(pos);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use a result parameter here?

@hpinkos
Copy link
Contributor Author

hpinkos commented Sep 27, 2013

@bagnell I fixed most of the things you mentioned, but I think I'll need help fixing the texture coordinates. After that, hopefully the tangents/binormals will better. Currently I'm using GeometryPipeline.computeBinormalAndTangent to compute them.


function computeRotationAngle(start, end, position, ellipsoid) {
var tangentPlane = new EllipsoidTangentPlane(position, ellipsoid);
var origin = tangentPlane.projectPointOntoPlane(position, originScratch);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always be Cartesian2.ZERO. You can remove this and the subtractions below.

@bagnell
Copy link
Contributor

bagnell commented Oct 1, 2013

I'm still seeing an issue similar to what @pjcozzi was seeing:
image
I modified the Polyline Volume Sandcastle example:

    var blueStar = new Cesium.GeometryInstance({
        geometry : new Cesium.PolylineVolumeGeometry({
            polylinePositions : ellipsoid.cartographicArrayToCartesianArray([
                Cesium.Cartographic.fromDegrees(-95.0, 32.0, 0.0),
                Cesium.Cartographic.fromDegrees(-95.0, 36.0, 100000.0),
                Cesium.Cartographic.fromDegrees(-95.0, 40.0, 100000.0)
            ]),
            vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
            shapePositions : starPositions(7, 70000, 50000),
            cornerType : Cesium.CornerType.ROUNDED
        }),
        attributes : {
            color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.BLUE)
        }
    });

@bagnell
Copy link
Contributor

bagnell commented Oct 1, 2013

It doesn't work for with any vertical segments:
image
I modified the same example to:

    var blueStar = new Cesium.GeometryInstance({
        geometry : new Cesium.PolylineVolumeGeometry({
            polylinePositions : ellipsoid.cartographicArrayToCartesianArray([
                Cesium.Cartographic.fromDegrees(-95.0, 32.0, 0.0),
                Cesium.Cartographic.fromDegrees(-95.0, 36.0, 100000.0),
                Cesium.Cartographic.fromDegrees(-95.0, 36.0, 200000.0)
            ]),
            vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
            shapePositions : starPositions(7, 70000, 50000),
            cornerType : Cesium.CornerType.ROUNDED
        }),
        attributes : {
            color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.BLUE)
        }
    });

You get this if you comment out the first position:
image

@hpinkos
Copy link
Contributor Author

hpinkos commented Oct 4, 2013

@bagnell alright, this is ready for review

@bagnell
Copy link
Contributor

bagnell commented Oct 4, 2013

Looks good. Merging.

bagnell added a commit that referenced this pull request Oct 4, 2013
@bagnell bagnell merged commit 183309f into master Oct 4, 2013
@bagnell bagnell deleted the polylineVolume branch October 4, 2013 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants